package siruna.WE.DeviceDependent.AndroidViews;

import java.util.HashMap;

import siruna.WE.core.events.Event;
import siruna.WE.core.model.VisualBlock;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;

public class ButtonRenderer extends Button {

	public ButtonRenderer(Context context, VisualBlock vb1) {
		super(context);
		final HashMap<String, String> attributes = vb1.getAttributes();
		final VisualBlock vb = vb1;
		LayoutParams wrapcontent = new LayoutParams(LayoutParams.WRAP_CONTENT,
				LayoutParams.WRAP_CONTENT);

		setText(attributes.get("text"));
		setLayoutParams(wrapcontent);

		setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				Event e = new Event(attributes.get("id"), attributes
						.get("onclick"), "geklikt op de knop");
				vb.getEventHandler().EventOccured(e);
			}
		});
	}

}
